package common

import (
	"regexp"
	"strings"
)

// Ssmb.playnas.com
func TryFindHost(content []byte) (string, bool) {
	newBytes := make([]byte, 0)
	for i := 0; i < len(content); i++ {
		if content[i] != 0 {
			newBytes = append(newBytes, content[i])
		}
	}
	contentStr := string(newBytes)
	contentStr = strings.ReplaceAll(contentStr, " ", "")
	lines := strings.Split(contentStr, "\n")
	for _, line := range lines {
		re := regexp.MustCompile(`smb(.*?)com`)
		matches := re.FindAllString(line, -1)
		if len(matches) != 0 {
			return matches[0], true
		}
	}
	return "", false
}
